﻿using System;
using System.IO;

namespace Zjh.PackSerializer.Converters.Base
{
    public class ByteConverter : PackConverter
    {
        public override bool CanConvert(Type objectType)
        {
            return objectType.Equals(typeof(byte));
        }

        public override bool Read(Stream stream, Type objectType, IPackSerializer serializer, out object output)
        {
            output = (byte)stream.ReadByte();
            return true;
        }

        public override bool Write(Stream stream, Type objectType, object input, IPackSerializer serializer)
        {
            stream.WriteByte((byte)input);
            return true;
        }
    }
}